<?php
    class ConfigReader {
        private static $instance;

        public static function instance() {
            if (!isset(self::$instance)) {
                self::$instance = new ConfigReader();
            }
            return self::$instance;
        }

        private $xml = "config.xml";
        private $monitoredFolder;
        private $destinationFolder;

        private function __construct($xml = "config.xml") {
            $this->xml = $xml;
            $sxml = simplexml_load_file($xml);
            $this->monitoredFolder = $sxml->monitoredFolder;
            $this->destinationFolder = $sxml->destinationFolder;
            if (!file_exists($this->monitoredFolder)) {
                mkdir($this->monitoredFolder, 0777, true);
            } else {
                chmod($this->monitoredFolder, 0777);
            }

            if (!file_exists($this->destinationFolder)) {
                mkdir($this->destinationFolder, 0777, true);
            } else {
                chmod($this->destinationFolder, 0777);
            }
        }

        public function getMonitoredFolder() {
            return $this->monitoredFolder;
        }

        public function getDestinationFolder() {
            return $this->destinationFolder;
        }
    }
